#include "blisp.h"

/*
blisp_Env *Env_new(void)
{
	return GC_NEW(blisp_Env);
}
*/

/*
 * Returns same pointer as parameter for convenience
 */
blisp_Env *Env_init(blisp_Env *env)
{
	env->syntax_tree = Pair_new(ONIL, OEMPTY);
	env->globals = Symbol_new("globals", ONIL);
	env->call_stack = GC_MALLOC(pow2(ENV_STK_SIZE) * sizeof(CallStkPos));
	env->call_stack_top = env->call_stack - 1;
	env->call_stack_size = ENV_STK_SIZE;
	env->data_stack = GC_MALLOC(pow2(ENV_STK_SIZE) * sizeof(StkPos));
	env->data_stack_top = env->data_stack - 1;
	env->data_stack_size = ENV_STK_SIZE;
	env->current_func = NULL;
	env->func_base = NULL;

	return env;
}

/*
 * Start a block, i.e. a list/pair/()
 */
void Env_pushBlock(blisp_Env *env)
{
	Env_cpush(env);
	memset(Env_ctos(env), 0, sizeof(Env_ctos(env)));
	Env_set_blk_open(env);
}

void Env_closeBlock(blisp_Env *env)
{
	if (!Env_get_blk_init(env))
		/* insert () */;
	/* TODO */
}
